package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.NewsComment;
import cn.wolfcode.trip.base.domain.TravelComment;
import cn.wolfcode.trip.base.mapper.NewsCommentMapper;
import cn.wolfcode.trip.base.mapper.TravelCommentMapper;
import cn.wolfcode.trip.base.query.NewsCommentQueryObject;
import cn.wolfcode.trip.base.query.TravelCommentQueryObject;
import cn.wolfcode.trip.base.service.INewsCommentService;
import cn.wolfcode.trip.base.service.ITravelCommentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class NewsCommentServiceImpl implements INewsCommentService {
    @Autowired
    private NewsCommentMapper newsCommentMapper;

    @Override
    public void saveComment(NewsComment newsComment) {
        newsComment.setReleaseTime(new Date());
        newsCommentMapper.saveNewsComment(newsComment);
    }

    @Override
    public PageInfo selectForList(NewsCommentQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<NewsComment> list = newsCommentMapper.selectForList(qo);
        return new PageInfo<>(list);
    }
}
